package org.sang.service;

import org.sang.common.UserUtils;
import org.sang.dao.MenuMapper;
import org.sang.beans.Menu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class MenuService {
    @Autowired
    MenuMapper menuMapper;

    /**
     * 获得所有菜单资源
     *
     * @return
     */
    public List<Menu> getAllMenu(){
        return menuMapper.getAllMenu();
    }

    /**
     * 根据用户ID查询用户可以查看的角色
     * @return
     */
    public List<Menu> getMenusByUserId() {
        return menuMapper.getMenusByUserId(UserUtils.getCurrentHr().getId());
    }

}
